
use.interval=0.0001
use.table=qnorm(seq(use.interval,1-use.interval,use.interval))
n.table.options=length(use.table)


simulate.DMC=function(N,params,maxCounter,stepSize,congruency,use.table,n.table.options) {
  
  rts=rep(0,N)
  resps=rep(0,N)
  
  gamma=params["gamma"]*congruency
  
  startPoints=(rbeta(N,params["betaDist"],params["betaDist"])*(params["a"]+params["a"]))-params["a"]
  
  
  tmp=.C("DMC",z=startPoints,v=params["v"],
         aU=params["a"],aL=-params["a"],
         gamma=gamma,alpha=params["alpha"],tau=params["tau"],
         s=params["stoch.s"],h=stepSize,resp=resps,rt=rts,
         n=N,maxiter=as.double(round(maxCounter)),
         rangeLow=as.integer(0),rangeHigh=as.integer(n.table.options-1),
         randomTable=as.double(use.table)) 
  
  tmp$rt=tmp$rt + rtnorm(N,params["ter"],params["terSD"],params["terTrunc"])
  
  out=list(rt=tmp$rt,resp=tmp$resp)
}

